package com.hanxiaozhang.order.constant;

/**
 * 〈一句话功能简述〉<br>
 * 〈订单类型枚举类〉
 *
 * @author hanxinghua
 * @create 2020/7/22
 * @since 1.0.0
 */
public enum OrderTypeEnum {

    //订单类型：0：日用品、1：服装、9：其他
    DAILY_NEED(0, "日用品"),
    CLOTHING(1, "服装"),
    OTHER(9, "其他");

    private Integer code;

    private String name;

    OrderTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }


    public String getName() {
        return name;
    }

    /**
     * 校验Code范围
     *
     * @param code
     * @return
     */
    public static boolean isValidCode(Integer code) {

        if (code == null) {
            return false;
        }

        for (OrderTypeEnum status : OrderTypeEnum.values()) {
            if (status.getCode().equals(code)) {
                return true;
            }
        }
        return false;
    }

}
